﻿using System;
using System.Web.Mvc;

namespace Avalon.Core.MVC.Attributes
{
    [AttributeUsage(AttributeTargets.Property)]
    public class IgnoreAttribute : Attribute, IMetadataAware
    {
        public const string Key = "Ignore";
        public bool Ignore { get; set; }

        public IgnoreAttribute(bool ignore)
        {
            Ignore = ignore;
        }

        public IgnoreAttribute() : this(true) { }


        public void OnMetadataCreated(ModelMetadata metadata)
        {
            metadata.AdditionalValues[Key] = Ignore;
        }
    }
}
